Skip to content

Ambaum 2020 saturation vapor pressure + phase handling - #3726

Merged
dopplershift merged 10 commits into
Unidata:mainfrom
dcamron:analytic-satvap
Apr 29, 2025
Merged

dopplershift merged 10 commits into
Unidata:mainfrom
dcamron:analytic-satvap

Conversation

@dcamron

@dcamron dcamron commented Dec 25, 2024 •

Copy link
Copy Markdown
Member

Dependent on #3725.

In a Christmas Eve sprint, I implemented the analytic saturation vapor pressure from Ambaum 2020, per recommendations from #626. Lots of updated test values, and these may change further, but I wanted to get the changes out there quickly so we could evaluate their impacts, as well as get the changes into the full test matrix.

All departures are small in relative magnitude, but some callouts for potential scrutiny:

  • test_lfc_ml
  • test_el and its extensions
  • any test involving cape_cin (mentioned in issue above as impacted, and needs LCL changes to see full picture.)
  • test_dewpoint_specific_humidity_xarray (I reduced the precision instead of redefining the test data)

test_equivalent_potential_temperature_masked worked before. The calculations work on the individual masked array elements but for some reason it blows up on the full array. numpy.ma.exp offered no help. If anyone has any insight here it had me pulling my hair out a bit. Marked this test, not the first time we've run into it in other contexts.

I'm not touching image tests until the other PR goes in and we tackle a review here, and maybe not even until LCL. Done.

To support LCL validation and future support of automatic LCL/LDL/LFL handling, I've built on (and credited) some previous work to enhance certain moisture calcs to support phase handling. In this case, saturation_vapor_pressure now supports water vapor equilibrium partial pressure over liquid and ice, and can automatically do so across the triple point temperature. I've plumbed this into moisture quantity calculations that depend on saturation vapor pressure as well.

I plan to follow up these changes with some tutorial and cookbook content in late Spring or early Summer.

Happy holidays! 🎅

@dcamron dcamron added Type: Maintenance Updates and clean ups (but not wrong) Area: Calc Pertains to calculations Subarea: Thermo Pertains to thermodynamic calculations and their physical correctness labels Dec 25, 2024
@dcamron
dcamron requested a review from a team as a code owner December 25, 2024 00:21
@dcamron
dcamron requested review from dopplershift and removed request for a team December 25, 2024 00:21
Cp_l = water_specific_heat = units.Quantity(4.2194, 'kJ / kg / K').to('J / kg / K')
Lv = water_heat_vaporization = units.Quantity(2.50084e6, 'J / kg')
Lf = water_heat_fusion = units.Quantity(3.337e5, 'J / kg')
Ls = water_heat_sublimation = Lv + Lf

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'Ls' is not used.
Cp_l = water_specific_heat = units.Quantity(4.2194, 'kJ / kg / K').to('J / kg / K')
Lv = water_heat_vaporization = units.Quantity(2.50084e6, 'J / kg')
Lf = water_heat_fusion = units.Quantity(3.337e5, 'J / kg')
Ls = water_heat_sublimation = Lv + Lf

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'water_heat_sublimation' is not used.
@dcamron dcamron changed the title Analytic satvap Analytic Saturation Vapor Pressure Dec 25, 2024
@dcamron
dcamron force-pushed the analytic-satvap branch 3 times, most recently from 1a9b663 to 2e3383f Compare December 26, 2024 18:04
@dcamron dcamron mentioned this pull request Dec 30, 2024
3 tasks done
@dopplershift dopplershift added this to the 1.7.0 milestone Jan 2, 2025
@dcamron
dcamron force-pushed the analytic-satvap branch 2 times, most recently from 4ff23a1 to 6b436fe Compare January 6, 2025 23:28
@dopplershift

dopplershift commented Jan 7, 2025 •

Copy link
Copy Markdown
Member

I think it makes sense to do this by itself. I don't understand why the test is failing with overflow in exp(). I can get the test suite to fail, but I can't get it to warn when running in a notebook.

EDIT: It's definitely overflowing, and we can just ignore in the test like we do on some others. In a notebook, it appears once and is then suppressed.

Comment thread src/metpy/calc/thermo.py Resolved
Comment thread src/metpy/calc/thermo.py
.. math:: 6.112 e^\frac{17.67T}{T + 243.5}
"""
latent_heat = water_latent_heat_vaporization._nounit(temperature)
heat_power = (mpconsts.nounit.Cp_l - mpconsts.nounit.Cp_v) / mpconsts.nounit.Rv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading through section 5, I don't think we should rely on our constants here, but use the tuned value for $C_{pl} - C_{pv}$ that's used in the paper, 2180 J / kg / K (eq. 14). Our values are essentially assuming an ideal gas for water vapor, and nominally for the triple point; the discussion in Ambaum 2020 explains how their value minimizes errors against empirical data from IAPWS95 in the 0-100 degC range.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to the idea that we allow users to override this value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will attach a figure summary of constant differences here later to justify neglecting this.

@dcamron dcamron changed the title Analytic Saturation Vapor Pressure Ambaum 2020 saturation vapor pressure + phase handling Apr 22, 2025
@dcamron
dcamron force-pushed the analytic-satvap branch 2 times, most recently from 9913aa0 to 448b5d9 Compare April 22, 2025 21:01
Comment thread src/metpy/calc/thermo.py
@process_units({'temperature': '[temperature]'}, '[pressure]')
def saturation_vapor_pressure(temperature):
r"""Calculate the saturation water vapor (partial) pressure.
def saturation_vapor_pressure(temperature, *, phase='liquid'):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
@dcamron
dcamron force-pushed the analytic-satvap branch 2 times, most recently from 11f85b0 to bfc19be Compare April 22, 2025 21:30
isilber and others added 4 commits April 28, 2025 12:28
Particularly improving usefullness of RH at low temperatures

See Unidata#2320
Update saturation vapor pressure to use simplified analytic expressions from Ambaum 2020. Allows for consistent assumptions across liquid and ice regimes and consistency for many modern downstream calculations: notably, incoming Romps LCL enhancement.
dcamron added 6 commits April 28, 2025 18:45
Build off drafted phase handling from community to calculate saturation vapor pressure over liquid, ice, or automatically across arrays based on freezing line. Add and test arbitrary kwarg validator for new phase kwarg. Add phase kwarg to calcs dependent on satvap, excluding dewpoint_from* calcs.

@dopplershift dopplershift left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

This branch was previously deployed

1 inactive deployment
CodeCov — 4e7f3620 Deployed Apr 29, 2025 by dcamron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Calc Pertains to calculations Subarea: Thermo Pertains to thermodynamic calculations and their physical correctness Type: Maintenance Updates and clean ups (but not wrong)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update saturation_vapor_pressure

5 participants